package com.gmp.thewizard;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;

public class WinAlertFragment extends DialogFragment {
	
	public static WinAlertFragment newInstance(int title){
		WinAlertFragment frag = new WinAlertFragment();
		Bundle args = new Bundle();
		args.putInt("title", title);
		frag.setArguments(args);
		return frag;
	}
	
	public Dialog onCreateDialog(Bundle savedInstanceState){
		int title = getArguments().getInt("title");
		
		return new AlertDialog.Builder(getActivity())
			.setTitle(title)
			.setMessage("You've WON!!!")
			.setCancelable(false)
			.setPositiveButton("Exit", new DialogInterface.OnClickListener(){
				public void onClick(DialogInterface dialog, int which){
					((GameActivity) getActivity()).settings.edit().remove("INTRO").commit();
					((GameActivity) getActivity()).finish();
				}
			})
			.setNegativeButton("Try Again", new DialogInterface.OnClickListener(){
				public void onClick(DialogInterface dialog, int which){
					((GameActivity) getActivity()).reload();
				}
			})
			.create();
	}
}
